package itman.elm.controller;

import itman.elm.po.User;
import itman.elm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/UserController")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     *根据用户编号与密码查询用户信息
     * @param user
     * @return
     * @throws Exception
     */
    @RequestMapping("/getUserByIdByPass")
    public User getUserByIdByPass(User user) throws Exception{
        return userService.getUserByIdByPass(user);
    }

    /**
     *根据用户编号查询用户表返回的行数
     * @param user
     * @return
     * @throws Exception
     */
    @RequestMapping("/getUserById")
    public int getUserById(User user) throws Exception{
        return userService.getUserById(user.getUserId());
    }

    /**
     *向用户表中添加一条记录
     * @param user
     * @return
     * @throws Exception
     */
    @RequestMapping("/saveUser")
    public int saveUser(User user) throws Exception{
        return userService.saveUser(user);
    }
}
